﻿@model IEnumerable<Gagnatek.WebSite.Models.Medias>
@{
    ViewBag.Title = "Index";
}
<h2>
    Index</h2>
<p>
    @if (User.IsInRole("Owner"))
    {
        @Html.ActionLink("Create New", "Create")
    }
    @using (Html.BeginForm("Search", "Medias")) {
    <label for="search">
        Search:
    </label>
    <input type="text" name="search" id="search" />
    <input type="submit" value="Search" />
    }
</p>
<table>
    <tr>
        <th>
            Nom
        </th>
        @if (User.IsInRole("Owner"))
        {
            <th>
                Description
            </th>

            <th>
                quantity
            </th>
        }
        <th>
            Type
        </th>
        <th>
            Auteur
        </th>
        <th>
        </th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.ActionLink(item.name, "Details", "Medias", new { id = item.id }, null)
                @* @Html.DisplayFor(modelItem => item.name)*@
            </td>
            @if (User.IsInRole("Owner"))
            {
                <td>
                    @Html.DisplayFor(modelItem => item.description)
                </td>

                <td>
                    @Html.DisplayFor(modelItem => item.quantity)
                </td>
            }
            <td>
                @Html.DisplayFor(modelItem => item.MediaTypes.name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Authors.name)
            </td>
            @if (User.IsInRole("Owner"))
            {
                <td>
                    @Html.ActionLink("Edit", "Edit", new { id = item.id }) |
                    @Html.ActionLink("Details", "Details", new { id = item.id }) |
                    @Html.ActionLink("Delete", "Delete", new { id = item.id })
                </td>
            }
        </tr>
    }
</table>
